// md5begin binomial
#ifdef BINOMIAL_LONG_LONG
  typedef long long binomial_type;
#else
  typedef int binomial_type;
#endif
const int MAX_BIN = 40;

binomial_type bin_coeffs[MAX_BIN][MAX_BIN];

void bin_init()
{
  for (int ii = 0; ii < MAX_BIN; ii++)
    for (int jj = 0; jj < MAX_BIN; jj++)
      bin_coeffs[ii][jj] = 0;
  for (int ii = 0; ii < MAX_BIN; ii++)
  {
    bin_coeffs[ii][0] = 1;
    bin_coeffs[ii][ii] = 1;
  }
}

binomial_type binomial(int n, int m)
{
  if (m < 0 || m > n)
    return 0;

  if (bin_coeffs[n][m] == 0)
    bin_coeffs[n][m] = binomial(n - 1, m) + binomial(n - 1, m - 1);

  return bin_coeffs[n][m];
}
// md5end binomial
